<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\agent\controller;

include_once LONGBING_EXTEND_PATH . "LongbingUpgrade.php";
class AppUpgrade extends \app\AdminRest
{
    public function getUpgradeInfo()
    {
        $goods_name = config("app.AdminModelList")["app_model_name"];
        $auth_uniacid = config("app.AdminModelList")["auth_uniacid"];
        $version_no = config("app.AdminModelList")["version_no"];
        $upgrade = new \LongbingUpgrade($auth_uniacid, $goods_name, \think\facade\Env::get("j2hACuPrlohF9BvFsgatvaNFQxCBCc", false));
        $data = $upgrade->checkAuth();
        $data["location_version_no"] = $version_no;
        $data["is_upgrade"] = $this->getIsUpgrade();
        $auth = new \app\industrytype\info\PermissionIndustrytype(666);
        $p_auth = $auth->pAuth();
        if($p_auth == 1) {
            $title = "按摩";
        } elseif($p_auth == 2) {
            $title = "上门";
        } else {
            $title = "全行业";
        }
        if(!empty($data["data"]["version"]["title"])) {
            $longbing_title = getConfigSetting(666, "longbing_title");
            $data["data"]["version"]["title"] = str_replace("龙兵", $longbing_title, $data["data"]["version"]["title"]);
            $data["data"]["version"]["title"] = str_replace("按摩", $title, $data["data"]["version"]["title"]);
        }
        return $this->success($data);
    }
    public function update()
    {
        $key = "init_all_data";
        setCache($key, "", 7200, $this->_uniacid);
        \app\admin\service\UpdateService::installSql($this->_uniacid);
        return $this->success([]);
    }
    private function getIsUpgrade()
    {
        if(!longbingIsWeiqin()) {
            return true;
        }
        return false;
    }
    public function upgrade()
    {
        if($this->getIsUpgrade()) {
            $goods_name = config("app.AdminModelList")["app_model_name"];
            $auth_uniacid = config("app.AdminModelList")["auth_uniacid"];
            $version_no = config("app.AdminModelList")["version_no"];
            $upgrade = new \LongbingUpgrade($auth_uniacid, $goods_name, \think\facade\Env::get("j2hACuPrlohF9BvFsgatvaNFQxCBCc", false));
            $file_temp_path = ROOT_PATH . "runtime/";
            $toFilePath = ROOT_PATH;
            $data = $upgrade->update($toFilePath, $file_temp_path);
            return $this->success($data);
        }
        return $this->success([]);
    }
}

?>